//
//  HWMainTabBarViewController.swift
//  WeiBo
//
//  Created by macbook on 16/6/27.
//  Copyright © 2016年 buWangChuXing. All rights reserved.
//

import UIKit

class HWMainTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        
        //替换自定义tab
        let tabBar = HWTabBar()
        tabBar.HWDelegate = self
        setValue(tabBar, forKey: "tabBar")
      
        //调用自定义的方法添加子控制
        addChildViewController(HWHomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(HWMessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        
        addChildViewController(HWDiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(HWProfileTableViewController(), title: "我", imageName: "tabbar_profile")
        
        
        
    }
  
    // MARK: - 自定义添加控制器方法
    func addChildViewController(vc:UIViewController,title:String,imageName:String){
        
        vc.title = title
        
        vc.tabBarItem.image = UIImage(named: imageName)
        vc.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")
        
        let naviagtionVc = UINavigationController(rootViewController: vc)
        addChildViewController(naviagtionVc)
        
    
    }
    
}

extension HWMainTabBarViewController:HWTabBarDelegate{

    func btnPushController() {
        
        print("弹出控制器")
    }

}











